home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / hypergraphMaterialMenu.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.6 KB  |  143 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // Copyright (C) 1997-1998 Alias|Wavefront,
  18. // a division of Silicon Graphics Limited.
  19. //
  20. // The information in this file is provided for the exclusive use of the
  21. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  22. // and incorporate this code into other products for purposes authorized
  23. // by the Alias|Wavefront license agreement, without fee.
  24. //
  25. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  26. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  27. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  28. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  29. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  30. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  31. // PERFORMANCE OF THIS SOFTWARE.
  32. //
  33. // $Source: /vobs/aw/Maya/src/RenderUISlice/UI/scripts/hypergraphMaterialMenu.mel $
  34. // 
  35. // $Author: awoo $
  36. // $Revision: /main/7 $
  37. // $Date: 2000/01/18 20:38:25 $
  38. // 
  39.  
  40. //
  41. //  Create context sensitive Hypergraph menu for shader nodes
  42. //  This is displayed with RMB on shader nodes
  43. //
  44. global proc hypergraphMaterialMenu(string $editor, string $menu, string $node)
  45. {
  46.     // The visor uses a hyper graph panel, so the only way to tell
  47.     // that we are in the visor is by the name
  48.     //
  49.     int $isVisor = gmatch( $editor, "*VisorEd" );
  50.  
  51.     setParent -m $menu;
  52.     menu -edit -deleteAllItems $menu;
  53.     
  54.     menuItem 
  55.         -l ("Material: " + $node)
  56.          MaterialMenuTitleItem;
  57.     menuItem -divider true;    
  58.     menuItem -divider true;    
  59.     if (!$isVisor)
  60.     {
  61.         menuItem 
  62.             -l "Graph Shader Network" 
  63.             -c ("hyperShade -shaderNetwork "+$node+" "+$editor)
  64.             MaterialUpstreamItem;
  65.     }
  66.     menuItem -divider true;    
  67.  
  68.     string $shadingGroupArray[] = 
  69.         `listConnections 
  70.             -source false 
  71.             -destination true 
  72.             -type "shadingEngine" 
  73.             $node`;
  74.  
  75.     int $isOceanShader = nodeType( $node ) == "oceanShader";
  76.     int $groupSize = size($shadingGroupArray);
  77.     if( $groupSize == 2 && $isOceanShader){
  78.         // OceanShaders are assigned twice to the same group:
  79.         // once for displacement and once for surfaceShading.
  80.         // Thus we get two identical groups, while we wish to display
  81.         // just one.
  82.         if( $shadingGroupArray[0] == $shadingGroupArray[1] ){
  83.             $groupSize = 1; // force use of "assign material"
  84.         }
  85.     }
  86.  
  87.     if( $groupSize <= 1)
  88.     {
  89.         if( $isOceanShader ){
  90.             menuItem 
  91.             -l "Assign Material To Selection" 
  92.             -c ("assignOceanShader " + $node) 
  93.             MaterialAssignItem;
  94.         } 
  95.         else
  96.         {
  97.             menuItem 
  98.                 -l "Assign Material To Selection" 
  99.                 -c ("hyperShade -assign " + $node) 
  100.                 MaterialAssignItem;
  101.         }
  102.         menuItem -divider true;    
  103.         menuItem -l "Select Objects With Material" 
  104.             -c ("hyperShade -objects " + $node) 
  105.             MaterialShowObjectsItem;
  106.         menuItem -l "Frame Objects With Material" 
  107.             -c ("hyperShade -objects " + $node + ";fitAllPanels -selected") 
  108.             MaterialFrameObjectsItem;
  109.     }
  110.     else
  111.     {
  112.         int $i;
  113.  
  114.         for ($i = 0; $i < size($shadingGroupArray); $i++)
  115.         {
  116.             menuItem 
  117.                 -l ("Assign " + $shadingGroupArray[$i] + " To Selection") 
  118.                 -c ("hyperShade -assign " + $shadingGroupArray[$i]);
  119.         }
  120.         menuItem -divider true;    
  121.  
  122.         for ($i = 0; $i < size($shadingGroupArray); $i++)
  123.         {
  124.             menuItem 
  125.                 -l ("Select Objects in " + $shadingGroupArray[$i]) 
  126.                 -c ("hyperShade -objects " + $shadingGroupArray[$i]);
  127.             menuItem 
  128.                 -l ("Frame Objects in " + $shadingGroupArray[$i]) 
  129.                 -c ("hyperShade -objects " 
  130.                     + $shadingGroupArray[$i] 
  131.                     + ";fitAllPanels -selected");
  132.         }
  133.     }
  134.     menuItem -divider true;
  135.     menuItem 
  136.         -l "Attribute Editor..."
  137.         -c ("hyperGraph -e -attributeEditor single -useFeedbackList " + $editor)
  138.         SingleAttrEditorItem;
  139.     menuItem -l "Rename"
  140.         -c ("hyperGraph -e -rename -useFeedbackList " + $editor) 
  141.         RenameItem;
  142. }
  143.